package com.um.jdy.common.charge.service.impl;


import com.um.jdy.common.device.dao.FeeEBoxPowerDao;
import com.um.jdy.common.device.entity.po.FeeEBoxPower;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import lombok.extern.slf4j.Slf4j;
import com.um.springboot.starter.orm.service.BaseEntityServiceImpl;
import com.um.jdy.common.charge.service.OrderEboxPowerService;
import com.um.jdy.common.charge.dao.OrderEboxPowerDao;
import com.um.jdy.common.charge.entity.po.OrderEboxPower;

import java.util.Date;
import java.util.List;

/**
 * 服务实现类：订单副本-充电柜功率档价格表
 */
@Service
@Slf4j
public class OrderEboxPowerServiceImpl extends BaseEntityServiceImpl<OrderEboxPowerDao,OrderEboxPower>  implements OrderEboxPowerService{

    @Autowired
    FeeEBoxPowerDao feeEBoxPowerDao;

    /**
     * 添加充电柜功率档位价格表
     *
     * @param feeId
     * @param orderId
     */
    @Override
    public void addOrderPower(String feeId, String orderId) {

        List<FeeEBoxPower> powers = feeEBoxPowerDao.getRows(new String[]{"device_fee_id"},new Object[]{feeId},
                new String[]{"start_power"},new String[]{"asc"});
        for(FeeEBoxPower power : powers){
            OrderEboxPower item = new OrderEboxPower();
            item.setChargeOrderId(orderId);
            item.setComId(power.getComId());
            item.setStartPower(power.getStartPower());
            item.setEndPower(power.getEndPower());
            item.setPrice(power.getPrice());
            item.setCreateTime(new Date());
            this.saveRow(item);
        }
    }
}
